Skip to content

feat(discord): add message context for replied messages#1084

Closed
liugangjian wants to merge 5 commits intosipeed:mainfrom
liugangjian:feat/1048-discord-message-context
Closed

feat(discord): add message context for replied messages#1084
liugangjian wants to merge 5 commits intosipeed:mainfrom
liugangjian:feat/1048-discord-message-context

Conversation

@liugangjian
Copy link

Description

Implements #1048

When Discord users reply to messages, the bot was only forwarding the new message text. The original quoted message content was lost, making it difficult for the LLM to understand context.

Changes

  1. Referenced Message Support: Read m.ReferencedMessage and add quoted content to the message
  2. Channel Mention Resolution: Parse <#123456789> to #channel-name
  3. Message Link Expansion: Expand Discord message links to include the linked message content (max 3 links)

Technical Details

  • Added enhanceMessageContent() function to process message context
  • Added resolveChannelMentions() to decode channel IDs
  • Added processMessageLinks() to expand message URLs
  • Graceful degradation when API queries fail

Testing

  • Added test cases for all new functionality
  • Verified with real Discord messages

Type of Change

  • New feature (non-breaking change which adds functionality)

AI Code Generation

  • 🤖 AI Assisted - Human designed the solution, AI helped implement it

liugangjian and others added 5 commits March 4, 2026 18:35
… JSON

When API endpoint is misconfigured (e.g., wrong api_base URL), the API
returns an HTML error page. Previously, the error message was cryptic:
"failed to unmarshal response: invalid character '<' looking for
beginning of value".

Now we detect HTML responses and provide a clear error message guiding
users to check their api_base URL configuration.

Fixes sipeed#1068

🤖 AI Code Generation: Fully AI generated - AI implemented the fix
and I reviewed and tested it
When restrict_to_workspace is true, guardCommand now properly skips
URL paths like 'wttr.in/Beijing' in curl commands. Previously, these
were incorrectly matched as relative paths and blocked.

Issue: sipeed#1042
Add isBinaryFile function to detect binary files (PDF, images, videos, etc.)
by checking the ratio of non-printable characters in the first 512 bytes.
When a binary file is detected, return an error message instead of
returning garbled content.

Fixes: sipeed#1049
Previously, the session flag was ignored in the agent command, with custom session keys
being replaced by the default routing session. The issue was caused by the code only
honoring session keys that started with the prefix 'agent:'.

This fix modifies the condition on how the session key is selected to honor any custom
session key provided via command line --session flag, regardless of prefix. Now the
custom session keys like "foobar" will generate "foobar.json" file instead of
"agent_main_main.json".

FIXES sipeed#1039

🤖 AI Assisted - Human designed the solution, AI helped implement it
Add test case verifying that read_file tool properly detects and rejects binary files such as PDFs with appropriate error message, preventing the generation of large amounts of garbage characters.
@sipeed-bot sipeed-bot bot added type: enhancement New feature or request domain: channel labels Mar 4, 2026
@alexhoshina
Copy link
Collaborator

Duplicate of #1047

@alexhoshina alexhoshina marked this as a duplicate of #1047 Mar 5, 2026
@alexhoshina alexhoshina self-assigned this Mar 5, 2026
@liugangjian
Copy link
Author

Closing as duplicate of #1047

@liugangjian liugangjian closed this Mar 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants